﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

using Lottery.Herper;

namespace Merge {
    public partial class MainForm : Form {
        public MainForm() {
            InitializeComponent();

            this.Text = "表格合并";

            grid1.InitGrid();
            grid2.InitGrid();
            gridResult.InitGrid();

            openFileDialog.FileName = string.Empty;
            label1.Text = m_file1;
            label2.Text = m_file2;
        }

        private string m_file1 = string.Empty;
        private string m_file2 = string.Empty;

        private void button1_Click(object sender, EventArgs e) {
            if (openFileDialog.ShowDialog() != DialogResult.OK) {
                return;
            }

            var fileName = openFileDialog.FileName;
            if (fileName == m_file2) {
                this.ShowInfo("当前文件和表格二相同");
                return;
            }

            m_file1 = fileName;
            label1.Text = m_file1;
        }

        private void button3_Click(object sender, EventArgs e) {
            if (string.IsNullOrEmpty(m_file1)) {
                this.ShowInfo("表格一没有调入");
                return;
            }
        }

        private void button2_Click(object sender, EventArgs e) {
            if (openFileDialog.ShowDialog() != DialogResult.OK) {
                return;
            }

            var fileName = openFileDialog.FileName;
            if (fileName == m_file1) {
                this.ShowInfo("当前文件和表格一相同");
                return;
            }

            m_file2 = fileName;
            label2.Text = m_file2;
        }
    }
}
